const mongoose = require("mongoose");
const dayjs = require("dayjs");

const NoticeSchema = new mongoose.Schema({
    title: {
        type: String,
        required: true,
    },
    content: {
        type: String,
        required: true,
        select: false,
    },
    status: {
        type: Number,
        default: 0,
        enum: [0, 1],
    },
    createAt: {
        type: String,
    },
});

NoticeSchema.pre("save", function (next) {
    this.createAt = dayjs().format("YYYY/MM/DD HH:mm:ss");
    next();
});

module.exports = mongoose.model("Notice", NoticeSchema);
